# 
# Created by francklinson on 2021/10/12 AT 10:09.
#
from typing import List


class Solution:
    def diStringMatch(self, s: str) -> List[int]:
        n = len(s)
        left, right = 0, n
        ans = []
        for i in range(n):
            if s[i] == 'I':
                ans.append(left)
                left += 1
            else:
                ans.append(right)
                right -= 1
        ans.append(left)
        return ans


if __name__ == '__main__':
    sol = Solution()
    print(sol.diStringMatch("IDID"))
    print(sol.diStringMatch("III"))
    print(sol.diStringMatch("DDD"))
